<?php
namespace app\index\controller;


header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:x-requested-with,content-type');
class Article extends Base
{
    function index(){
        $articleList = Db('article')->field('id,photo')->select();   //滚动图
        if($articleList){
            foreach ($articleList as &$v){
                $v['photo'] = '/uploads/images/'.$v['photo'];
            }
        }
        return json(['code'=>1,'data'=>$articleList]);
    }
    /**
     * 查询文章详情
     * @return [type] [description]
     */
	public function info($aid=0){
	    if(!$aid){
	        $this->error('数据异常');
        }
        $info = Db('article')->where('id',$aid)->field('id,title,content,create_time')->find();
        $info['create_time'] = date('Y-m-d H:i:s',$info['create_time']);
        $this->assign('info',$info);
        return $this->fetch();
	}

}